<?php
class UserInfo extends Action {
	/* (non-PHPdoc)
	 * @see Action::execute()
	 */
	public function execute($params) {
		$me = check_login ( ADMIN_LOGIN_PAGE );
		
		$uid = $me->uid;
		$user = sess_del ( 'user_info', false );
		if (! $user) {
			$userModel = new CoreUserModel ();
			$user = $userModel->read ( $uid );
		}
		if ($user == false) {
			$data ['page_tip_info'] = "<strong>出错啦!</strong>uid为{$uid}的用户不存在。";
		} else {
			$data = $user;
			$data ['user'] = $user;
			$data ['page_tip_info'] = sess_del ( 'page_tip_info', false );
		}
		bind ( 'get_userinfo_tpl', array ($this, 'get_userinfo_tpl' ), 1, 2 );
		$suc = sess_del ( 'edit_user_info_rst', false );
		$data ['alert_cls'] = $suc ? 'alert-success' : 'alert-error';
		$data ['error'] = sess_del ( 'user_error', array () );
		$data ['error_cls'] = ModelValidator::getErrorCls ( $data ['error'] );
		$data ['group'] = rqst ( 'group', 'base' );
		$data ['opt_groups'] = apply_filter ( 'get_userinfo_group', array ('base' => '基本资料' ) );
		$data ['userinfo_tpl'] = apply_filter ( 'get_userinfo_tpl', '', $data ['group'] );
		$data = apply_filter ( 'get_userinfo_data', $data );
		return new SmartyView ( $data, 'users/UserInfo' );
	}
	public function get_userinfo_tpl($tpl, $group) {
		if ($group == 'base') {
			return 'core/views/users/UserInfoBase.tpl';
		}
		return '';
	}
}